import java.util.Set;
//该字符串是否可以分割成 字典中的单词
public class WordBreak {
    public boolean wordBreak(String s, Set<String> dict) {
        boolean[] canBreak = new boolean[s.length() + 1];
        canBreak[0] = true;
        for (int i = 1; i <= s.length(); ++i) {
            for (int j = 0; j < i; ++j) {
                if(canBreak[i] && dict.contains(s.substring(j,i))) {
                    canBreak[i] = true;
                    break;
                }

            }

        }
        return canBreak[s.length()];
    }
}
